import { Column, Entity, Index, PrimaryGeneratedColumn } from "typeorm";

@Index("order_no", ["orderNo"], { unique: true })
@Entity("charge_order", { schema: "frog_charge" })
export class ChargeOrder {
  @PrimaryGeneratedColumn({ type: "int", name: "order_id", unsigned: true })
  orderId: number;

  @Column("varchar", { name: "order_no", unique: true, length: 20 })
  orderNo: string;

  @Column("int", {
    name: "user_id",
    comment: "id",
    unsigned: true,
    default: () => "'0'",
  })
  userId: number;

  @Column("int", { name: "merchant_id", unsigned: true, default: () => "'0'" })
  merchantId: number;

  @Column("int", { name: "port_id", unsigned: true, default: () => "'0'" })
  portId: number;

  @Column("tinyint", {
    name: "client_source",
    comment: ",1:2",
    unsigned: true,
    default: () => "'0'",
  })
  clientSource: number;

  @Column("int", { name: "device_id", unsigned: true, default: () => "'0'" })
  deviceId: number;

  @Column("int", {
    name: "strategy_id",
    comment: "Id",
    unsigned: true,
    default: () => "'0'",
  })
  strategyId: number;

  @Column("tinyint", { name: "port_no", unsigned: true, default: () => "'0'" })
  portNo: number;

  @Column("tinyint", { name: "strategy_type", default: () => "'0'" })
  strategyType: number;

  @Column("json", { name: "strategy_rules", nullable: true })
  strategyRules: object | null;

  @Column("decimal", {
    name: "unit_price",
    precision: 4,
    scale: 2,
    default: () => "'0.00'",
  })
  unitPrice: string;

  @Column("float", {
    name: "settle_unit",
    unsigned: true,
    precision: 12,
    default: () => "'0'",
  })
  settleUnit: number;

  @Column("decimal", {
    name: "charge_amount",
    precision: 5,
    scale: 2,
    default: () => "'0.00'",
  })
  chargeAmount: string;

  @Column("decimal", {
    name: "fee_amount",
    precision: 5,
    scale: 2,
    default: () => "'0.00'",
  })
  feeAmount: string;

  @Column("decimal", {
    name: "fee_reward_amount",
    precision: 5,
    scale: 2,
    default: () => "'0.00'",
  })
  feeRewardAmount: string;

  @Column("decimal", {
    name: "consume_amount",
    precision: 5,
    scale: 2,
    default: () => "'0.00'",
  })
  consumeAmount: string;

  @Column("tinyint", {
    name: "stop_reason",
    unsigned: true,
    default: () => "'0'",
  })
  stopReason: number;

  @Column("json", { name: "charge_data", nullable: true })
  chargeData: object | null;

  @Column("tinyint", {
    name: "status",
    comment: "0:,1:,2:3",
    unsigned: true,
    default: () => "'0'",
  })
  status: number;

  @Column("tinyint", {
    name: "error_code",
    unsigned: true,
    default: () => "'0'",
  })
  errorCode: number;

  @Column("int", { name: "create_time", unsigned: true, default: () => "'0'" })
  createTime: number;

  @Column("int", { name: "end_time", unsigned: true, default: () => "'0'" })
  endTime: number;
}
